
{if $deptInfo}
<b>{$deptInfo}</b>
<table border=1 cellspacing="10px" width="450px">
    {php}$count = 0; $this->assign('count', $count);{/php}
    {foreach from=$rooms item=room}
        {if $count % 3 == 0}
            <tr height="50px">
        {/if}
                <td width="150px">
                    <a href="javascript:getBedsOfRoom('{$room.room_id}');">{$room.room_name}</a><br>
                    {$room.empty_beds}&nbsp;{translate}empty bed(s){/translate}
                </td>
        {if $count % 3 == 2}
            </tr>
        {/if}
        {php}$count++; $this->assign('count', $count);{/php}
    {/foreach}
    {if $count % 3 == 1}
            <td style="border:none;/>
            <td style="border:none;/>
        </tr>
    {elseif $count % 3 == 2}
            <td style="border:none;/>
        </tr>
    {/if}
</table>

{elseif $roomInfo}
<b>{$roomInfo}</b>
<a class='imgBtn' href="javascript:viewBedStatus();">
    <img title='{translate}Back{/translate}' src="../images/back.gif"/>
</a>
<p>{translate}White: Available bed - Red: Full bed{/translate}</p>
<table border=1 cellspacing="10px" width="450px">
    {php}$count = 0; $this->assign('count', $count);{/php}
    <!-- with each bed -->
    {foreach from=$beds item=bed}
        <!-- if bed is full, mark background as red color -->
        {if $bed.patients < $bed.max_patients}
            {assign var='bedStyle' value="width:150px;"}
            {assign var='ref' value=''}
        {else}
            {assign var='bedStyle' value="width:150px;background-color:#FF0000;"}
            {assign var='ref' value='#nogo'}
        {/if}
        <!-- show number of patients -->
        {assign var='currentPatients' value=$bed.patients}
        {php}        
            $patientImgs = '';
            $currentPatients = $this->get_template_vars('currentPatients');            
            for ($i = 0; $i < $currentPatients; $i++) {
                $patientImgs = $patientImgs . "<img src='../images/person.png' />";
            }
            $this->assign('patientImgs', $patientImgs);
        {/php}     
        {if $count % 3 == 0}
            <tr height="50px">
        {/if}
                <td style="{$bedStyle}">
	                {if $ref == '#nogo'}
	                <a href='{$ref}'>{$bed.code}</a><br />
	                {else}
	                <a href="javascript: selectBed('{$bed.bed_id}','{$bed.code}','{$roomName}')">{$bed.code}</a><br />
	                {/if}
                    {$patientImgs}              
                </td>
        {if $count % 3 == 2}
            </tr>
        {/if}
        {php}$count++; $this->assign('count', $count);{/php}
    {/foreach}
    {if $count % 3 == 1}
            <td style="border:none;/>
            <td style="border:none;/>
        </tr>
    {elseif $count % 3 == 2}
            <td style="border:none;/>
        </tr>
    {/if}
</table>
{/if}